package com.lost.octopus.es.helper.entity.query;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 返回数据
 * @author zhangbh
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class QueryResult<T> implements Serializable {

    private static final long serialVersionUID = 2984821237375788405L;
    private PageOut page;
    private List<T> list;

    public static <T> QueryResult<T> of(PageOut page, List<T> list) {
        return new QueryResult<>(page, list);
    }

    public static <T> QueryResult<T> empty(int currentPage, int pageSize) {
        return new QueryResult<>(new PageOut(currentPage, pageSize, 0), new ArrayList<>());
    }
}
